// Fill out your copyright notice in the Description page of Project Settings.
#include "SCustomCurveList.h"
#include "SlateOptMacros.h"
#include "Blueprint/WidgetBlueprintLibrary.h"
#include "Kismet/KismetMathLibrary.h"
#include "ListLibrary/GlobalConfig.h"
#include "ListLibrary/BaseWidget/SCollisionScrollBox_List.h"
#include "ListLibrary/BaseWidget/STextBlock_TextStyleLambda_List.h"
#include "Slate/SlateBrushAsset.h"
#include "Widgets/Colors/SColorBlock.h"
#include "Widgets/Images/SImage.h"
#include "Widgets/Input/SSlider.h"
#include "Widgets/Layout/SConstraintCanvas.h"
#include "Widgets/Layout/SSpacer.h"
#include "Widgets/Notifications/SNotificationList.h"
#include "Widgets/Notifications/SProgressBar.h"
#include "Widgets/Text/SMultiLineEditableText.h"

BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION


SCustomCurveList::SCustomCurveList()
	: MaxValue(100)
	  , MinValue(0)
	  , GrowValue(20)
	  , PillarNum(1)
	  , SpacerDrawArea(nullptr)
	  , UseCurveLine(false)
	  , ShowArea(false)
	  , SizeUpdata(false)
	  , ShowTitle(true)
	  , ShowYuan(false)
	  , UseRand(true)
	  , BaiSlateBrush(nullptr)
	  , LvSlateBrush(nullptr)
	  , BlueSlateBrush(nullptr)
	  , YellowSlateBrush(nullptr)
{
	BaiSlateBrush = NewObject<USlateBrushAsset>();
	LvSlateBrush = NewObject<USlateBrushAsset>();
	BlueSlateBrush = NewObject<USlateBrushAsset>();
	YellowSlateBrush = NewObject<USlateBrushAsset>();
	YuanBrush = NewObject<USlateBrushAsset>();
	if (BaiSlateBrush)
	{
		BaiSlateBrush->Brush = *ListUIStyle::GetImage("BaiJianBian");
		BaiSlateBrush->AddToRoot();
	}
	if (LvSlateBrush)
	{
		LvSlateBrush->Brush = *ListUIStyle::GetImage("LvJianBian");
		LvSlateBrush->AddToRoot();
	}
	if (BlueSlateBrush)
	{
		BlueSlateBrush->Brush = *ListUIStyle::GetImage("BlueJianBian");
		BlueSlateBrush->AddToRoot();
	}
	if (YellowSlateBrush)
	{
		YellowSlateBrush->Brush = *ListUIStyle::GetImage("YellowJianBian");
		YellowSlateBrush->AddToRoot();
	}
	if(YuanBrush)
	{
		YuanBrush->Brush = *ListUIStyle::GetImage("Yuan");
		YuanBrush->AddToRoot();
	}
}

void SCustomCurveList::Construct(const FArguments& InArgs)
{
	ChildSlot
	[
		SNew(SVerticalBox)
		+ SVerticalBox::Slot().AutoHeight()
		[
			SNew(SHorizontalBox)
			.Visibility_Lambda([this]()
			{
				if (ShowTitle)
					return EVisibility::Visible;
				else
					return EVisibility::Collapsed;
			})
			+ SHorizontalBox::Slot().AutoWidth()
			[
				SAssignNew(TitleText, STextBlock_TextStyleLambda_List)
				.Justification(ETextJustify::Left)
				.Text(FText::FromString(InArgs._Title))
				.TEXTSTYLE(InArgs._TitleStrStyle)
			]
			+ SHorizontalBox::Slot().FillWidth(1)
			[
				SNew(SSpacer)
			]
			+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center)
			[
				SNew(SBox).WidthOverride(8).HeightOverride(8)
				[
					SNew(SImage)
					.SETIMAGE("ZhuZi_Blue")
				]
			]
			+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center).Padding(FMargin(6, 0, 0, 0))
			[
				SAssignNew(OneInfo, STextBlock_TextStyleLambda_List)
				.Justification(ETextJustify::Left)
				.Text(FText::FromString(InArgs._ColorOneInfo))
				.TEXTSTYLE("AlibabaRegular_11_83AAD6FF")
			]
			+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center).Padding(FMargin(16, 0, 0, 0))
			[
				SNew(SBox).WidthOverride(8).HeightOverride(8)
				          .Visibility_Lambda([this]()
				          {
					          if (PillarNum >= 2)
						          return EVisibility::Visible;
					          else
					          {
						          return EVisibility::Collapsed;
					          }
				          })
				[
					SNew(SImage)
					.SETIMAGE("ZhuZi_Green")
				]
			]
			+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center).Padding(FMargin(6, 0, 0, 0))
			[
				SAssignNew(TwoInfo, STextBlock_TextStyleLambda_List)
				.Visibility_Lambda([this]()
				                                                    {
					                                                    if (PillarNum >= 2)
						                                                    return EVisibility::Visible;
					                                                    else
					                                                    {
						                                                    return EVisibility::Collapsed;
					                                                    }
				                                                    })
				.Justification(ETextJustify::Left)
				.Text(FText::FromString(InArgs._ColorTwoInfo))
				.TEXTSTYLE("AlibabaRegular_11_83AAD6FF")
			]
			+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center).Padding(FMargin(16, 0, 0, 0))
			[
				SNew(SBox).WidthOverride(8).HeightOverride(8)
				          .Visibility_Lambda([this]()
				          {
					          if (PillarNum >= 3)
						          return EVisibility::Visible;
					          else
					          {
						          return EVisibility::Collapsed;
					          }
				          })
				[
					SNew(SImage)
					.SETIMAGE("ZhuZi_Yellow")
				]
			]
			+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center).Padding(FMargin(6, 0, 0, 0))
			[
				SAssignNew(ThreeInfo, STextBlock_TextStyleLambda_List)
				.Visibility_Lambda([this]()
				                                                      {
					                                                      if (PillarNum >= 3)
						                                                      return EVisibility::Visible;
					                                                      else
					                                                      {
						                                                      return EVisibility::Collapsed;
					                                                      }
				                                                      })
				.Justification(ETextJustify::Left)
				.Text(FText::FromString(InArgs._ColorThreeInfo))
				.TEXTSTYLE("AlibabaRegular_11_83AAD6FF")
			]
			+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center).Padding(FMargin(16, 0, 0, 0))
			[
				SNew(SBox).WidthOverride(8).HeightOverride(8)
				          .Visibility_Lambda([this]()
				          {
					          if (PillarNum >= 4)
						          return EVisibility::Visible;
					          else
					          {
						          return EVisibility::Collapsed;
					          }
				          })
				[
					SNew(SImage)
					.SETIMAGE("ZhuZi_White")
				]
			]
			+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center).Padding(FMargin(6, 0, 0, 0))
			[
				SAssignNew(FourInfo, STextBlock_TextStyleLambda_List)
				.Visibility_Lambda([this]()
				                                                     {
					                                                     if (PillarNum >= 4)
						                                                     return EVisibility::Visible;
					                                                     else
					                                                     {
						                                                     return EVisibility::Collapsed;
					                                                     }
				                                                     })
				.Justification(ETextJustify::Left)
				.Text(FText::FromString(InArgs._ColorFourInfo))
				.TEXTSTYLE("AlibabaRegular_11_83AAD6FF")
			]
		]
		+ SVerticalBox::Slot().FillHeight(1).Padding(FMargin(0, 16, 0, 0))
		[
			SAssignNew(ListContent, SBox)
		]
	];
}

END_SLATE_FUNCTION_BUILD_OPTIMIZATION


int32 SCustomCurveList::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{
	SCompoundWidget::OnPaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled);

	if (SpacerDrawArea == nullptr || ListData.Num() == 0)
		return LayerId;


	//AbsolutePosition代表再父类中的位置
	if (SizeUpdata)
	{
		for (int i = 0; i < CenterS.Num(); i++)
		{
			TArray<FVector2D> Points;
			Points.Add(CenterS[i]);
			Points.Add(CenterS[i]);

			FSlateDrawElement::MakeLines( //绘制线条
				OutDrawElements,
				LayerId++,
				AllottedGeometry.ToPaintGeometry(),
				Points, //线条坐标
				bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, //在原色基础之上在增加别的效果
				FLinearColor(1, 0, 0, 1), //显示颜色
				true, //抗锯齿
				1 * (AllottedGeometry.Scale < 1.0 ? 1 : AllottedGeometry.Scale) //线的宽度
			);
		}
		//显示面积
		if (PillarNum >= 1)
		{
			if (ShowArea)
			{
				for (int i = 0; i < OnePointY.Num(); i++)
				{
					TArray<FSlateGradientStop> GradientStops;
					FWidgetStyle ImportantStyle;
					ImportantStyle.SetForegroundColor(FLinearColor(1, 1, 1, 1));
					FPaintContext tempParams(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, ImportantStyle, bParentEnabled && IsEnabled());
					FVector2D BeginP = FVector2D(OnePointY[i].X - 0.5, OnePointY[i].Y + 0.2);
					FVector2D EndP = FVector2D(OnePointY[i].X + 0.5, Size.Y + BeginPoint.Y);
					UWidgetBlueprintLibrary::DrawBox(tempParams, BeginP, EndP - BeginP, BlueSlateBrush);
				}
			}

			if (UseCurveLine)
			{
				for (int i = 0; i < OnePointS.Num(); i++)
				{
					TArray<FVector2D> Points;
					Points.Add(OnePointS[i]);
					Points.Add(FVector2D(OnePointS[i].X + 0.01, OnePointS[i].Y + 0.01));

					FSlateDrawElement::MakeLines( //绘制线条
						OutDrawElements,
						LayerId++,
						AllottedGeometry.ToPaintGeometry(),
						Points, //线条坐标
						bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, //在原色基础之上在增加别的效果
						FLinearColor(0.007, 0.3, 0.99, 1), //显示颜色
						true, //抗锯齿
						1 * (AllottedGeometry.Scale < 1.0 ? 1 : AllottedGeometry.Scale) //线的宽度
					);
				}
			}
			else
			{
				FSlateDrawElement::MakeLines( //绘制线条
					OutDrawElements,
					LayerId++,
					AllottedGeometry.ToPaintGeometry(),
					OnePointS, //线条坐标
					bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, //在原色基础之上在增加别的效果
					FLinearColor(0.007, 0.3, 0.99, 1), //显示颜色
					true, //抗锯齿
					2 * (AllottedGeometry.Scale < 1.0 ? 1 : AllottedGeometry.Scale) //线的宽度
				);
			}
			if(ShowYuan)
			{
				for(int i = 0; i < OnePointS.Num();i++)
				{
					FSlateDrawElement::MakeBox(
						OutDrawElements,
						++LayerId,
						AllottedGeometry.ToPaintGeometry( OnePointS[i] - ( YuanBrush->Brush.ImageSize / 2 ), YuanBrush->Brush.ImageSize ),
						&(YuanBrush->Brush)
					);
				}
				int i = 0;
				for (auto &item : CopyListData)
				{
					i++;
					const FText Text = FText::FromString(FString::SanitizeFloat(item.Value.OneValue));
					FSlateDrawElement::MakeText(//绘制字符
						OutDrawElements,
						LayerId++,
						AllottedGeometry.ToPaintGeometry(OnePointS[i] - YuanBrush->Brush.ImageSize, AllottedGeometry.GetLocalSize(), 1.0),//坐标大小
						Text.ToString(),//字符串
						ListUIStyle::GetFont("AlibabaRegular",12),//字体信息
						bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect,//绘制效果
						FColor(255, 255, 255)//字体的颜色
					);
				}
			}
		}
		if (PillarNum >= 2)
		{
			if (ShowArea)
			{
				for (int i = 0; i < TwoPointY.Num(); i++)
				{
					TArray<FSlateGradientStop> GradientStops;
					FWidgetStyle ImportantStyle;
					ImportantStyle.SetForegroundColor(FLinearColor(1, 1, 1, 1));
					FPaintContext tempParams(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, ImportantStyle, bParentEnabled && IsEnabled());
					FVector2D BeginP = FVector2D(TwoPointY[i].X - 0.5, TwoPointY[i].Y + 0.2);
					FVector2D EndP = FVector2D(TwoPointY[i].X + 0.5, Size.Y + BeginPoint.Y);
					UWidgetBlueprintLibrary::DrawBox(tempParams, BeginP, EndP - BeginP, LvSlateBrush);
				}
			}
			if (UseCurveLine)
			{
				for (int i = 0; i < TwoPointS.Num(); i++)
				{
					TArray<FVector2D> Points;
					Points.Add(TwoPointS[i]);
					Points.Add(FVector2D(TwoPointS[i].X + 0.01, TwoPointS[i].Y + 0.01));

					FSlateDrawElement::MakeLines( //绘制线条
						OutDrawElements,
						LayerId++,
						AllottedGeometry.ToPaintGeometry(),
						Points, //线条坐标
						bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, //在原色基础之上在增加别的效果
						FLinearColor(0.034, 1, 0.5, 1), //显示颜色
						true, //抗锯齿
						1 * (AllottedGeometry.Scale < 1.0 ? 1 : AllottedGeometry.Scale) //线的宽度
					);
				}
			}
			else
			{
				FSlateDrawElement::MakeLines( //绘制线条
					OutDrawElements,
					LayerId++,
					AllottedGeometry.ToPaintGeometry(),
					TwoPointS, //线条坐标
					bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, //在原色基础之上在增加别的效果
					FLinearColor(0.034, 1, 0.5, 1), //显示颜色
					true, //抗锯齿
					2 * (AllottedGeometry.Scale < 1.0 ? 1 : AllottedGeometry.Scale) //线的宽度
				);
			}
			if(ShowYuan)
			{
				for(int i = 0; i < TwoPointS.Num();i++)
				{
					FSlateDrawElement::MakeBox(
						OutDrawElements,
						++LayerId,
						AllottedGeometry.ToPaintGeometry( TwoPointS[i] - ( YuanBrush->Brush.ImageSize / 2 ), YuanBrush->Brush.ImageSize ),
						&(YuanBrush->Brush)
					);
				}
				int i = 0;
                for (auto &item : CopyListData)
                {
                	i++;
                	const FText Text = FText::FromString(FString::SanitizeFloat(item.Value.TwoValue));
                	FSlateDrawElement::MakeText(//绘制字符
                		OutDrawElements,
                		LayerId++,
                		AllottedGeometry.ToPaintGeometry(TwoPointS[i] - YuanBrush->Brush.ImageSize, AllottedGeometry.GetLocalSize(), 1.0),//坐标大小
                		Text.ToString(),//字符串
                		ListUIStyle::GetFont("AlibabaRegular",12),//字体信息
                		bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect,//绘制效果
                		FColor(255, 255, 255)//字体的颜色
                	);
                }
			}
		}
		if (PillarNum >= 3)
		{
			if (ShowArea)
			{
				for (int i = 0; i < ThreePointY.Num(); i++)
				{
					TArray<FSlateGradientStop> GradientStops;
					FWidgetStyle ImportantStyle;
					ImportantStyle.SetForegroundColor(FLinearColor(1, 1, 1, 1));
					FPaintContext tempParams(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, ImportantStyle, bParentEnabled && IsEnabled());
					FVector2D BeginP = FVector2D(ThreePointY[i].X - 0.5, ThreePointY[i].Y + 0.2);
					FVector2D EndP = FVector2D(ThreePointY[i].X + 0.5, Size.Y + BeginPoint.Y);
					UWidgetBlueprintLibrary::DrawBox(tempParams, BeginP, EndP - BeginP, BaiSlateBrush);
				}
			}
			if (UseCurveLine)
			{
				for (int i = 0; i < ThreePointS.Num(); i++)
				{
					TArray<FVector2D> Points;
					Points.Add(ThreePointS[i]);
					Points.Add(FVector2D(ThreePointS[i].X + 0.01, ThreePointS[i].Y + 0.01));

					FSlateDrawElement::MakeLines( //绘制线条
						OutDrawElements,
						LayerId++,
						AllottedGeometry.ToPaintGeometry(),
						Points, //线条坐标
						bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, //在原色基础之上在增加别的效果
						FLinearColor(0.6, 0.7, 0.8, 1), //显示颜色
						true, //抗锯齿
						1 * (AllottedGeometry.Scale < 1.0 ? 1 : AllottedGeometry.Scale) //线的宽度
					);
				}
			}
			else
			{
				FSlateDrawElement::MakeLines( //绘制线条
					OutDrawElements,
					LayerId++,
					AllottedGeometry.ToPaintGeometry(),
					ThreePointS, //线条坐标
					bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, //在原色基础之上在增加别的效果
					FLinearColor(0.6, 0.7, 0.8, 1), //显示颜色
					true, //抗锯齿
					2 * (AllottedGeometry.Scale < 1.0 ? 1 : AllottedGeometry.Scale) //线的宽度
				);
			}
			if(ShowYuan)
			{
				for(int i = 0; i < ThreePointS.Num();i++)
				{
					FSlateDrawElement::MakeBox(
						OutDrawElements,
						++LayerId,
						AllottedGeometry.ToPaintGeometry( ThreePointS[i] - ( YuanBrush->Brush.ImageSize / 2 ), YuanBrush->Brush.ImageSize ),
						&(YuanBrush->Brush)
					);
				}
				int i = 0;
				for (auto &item : CopyListData)
				{
					i++;
					const FText Text = FText::FromString(FString::SanitizeFloat(item.Value.ThreeValue));
					FSlateDrawElement::MakeText(//绘制字符
						OutDrawElements,
						LayerId++,
						AllottedGeometry.ToPaintGeometry(ThreePointS[i] - YuanBrush->Brush.ImageSize, AllottedGeometry.GetLocalSize(), 1.0),//坐标大小
						Text.ToString(),//字符串
						ListUIStyle::GetFont("AlibabaRegular",12),//字体信息
						bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect,//绘制效果
						FColor(255, 255, 255)//字体的颜色
					);
				}
			}
		}
		if (PillarNum >= 4)
		{
			if (ShowArea)
			{
				for (int i = 0; i < FourPointY.Num(); i++)
				{
					TArray<FSlateGradientStop> GradientStops;
					FWidgetStyle ImportantStyle;
					ImportantStyle.SetForegroundColor(FLinearColor(1, 1, 1, 1));
					FPaintContext tempParams(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, ImportantStyle, bParentEnabled && IsEnabled());
					FVector2D BeginP = FVector2D(FourPointY[i].X - 0.5, FourPointY[i].Y + 0.2);
					FVector2D EndP = FVector2D(FourPointY[i].X + 0.5, Size.Y + BeginPoint.Y);
					UWidgetBlueprintLibrary::DrawBox(tempParams, BeginP, EndP - BeginP, YellowSlateBrush);
				}
			}
			if (UseCurveLine)
			{
				for (int i = 0; i < FourPointS.Num(); i++)
				{
					TArray<FVector2D> Points;
					Points.Add(FourPointS[i]);
					Points.Add(FVector2D(FourPointS[i].X + 0.01, FourPointS[i].Y + 0.01));

					FSlateDrawElement::MakeLines( //绘制线条
						OutDrawElements,
						LayerId++,
						AllottedGeometry.ToPaintGeometry(),
						Points, //线条坐标
						bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, //在原色基础之上在增加别的效果
						FLinearColor(0.99, 0.59, 0.2, 1), //显示颜色
						true, //抗锯齿
						1 * (AllottedGeometry.Scale < 1.0 ? 1 : AllottedGeometry.Scale) //线的宽度
					);
				}
			}
			else
			{
				FSlateDrawElement::MakeLines( //绘制线条
					OutDrawElements,
					LayerId++,
					AllottedGeometry.ToPaintGeometry(),
					FourPointS, //线条坐标
					bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect, //在原色基础之上在增加别的效果
					FLinearColor(0.99, 0.59, 0.2, 1), //显示颜色
					true, //抗锯齿
					2 * (AllottedGeometry.Scale < 1.0 ? 1 : AllottedGeometry.Scale) //线的宽度
				);
			}
			if(ShowYuan)
			{
				for(int i = 1; i < FourPointS.Num() -1;i++)
				{
					FSlateDrawElement::MakeBox(
						OutDrawElements,
						++LayerId,
						AllottedGeometry.ToPaintGeometry( FourPointS[i] - ( YuanBrush->Brush.ImageSize / 2 ), YuanBrush->Brush.ImageSize ),
						&(YuanBrush->Brush)
					);
				}
				int i = 0;
				for (auto &item : CopyListData)
				{
					i++;
					const FText Text = FText::FromString(FString::SanitizeFloat(item.Value.FourValue));
					FSlateDrawElement::MakeText(//绘制字符
						OutDrawElements,
						LayerId++,
						AllottedGeometry.ToPaintGeometry(FourPointS[i] - YuanBrush->Brush.ImageSize, AllottedGeometry.GetLocalSize(), 1.0),//坐标大小
						Text.ToString(),//字符串
						ListUIStyle::GetFont("AlibabaRegular",12),//字体信息
						bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect,//绘制效果
						FColor(255, 255, 255)//字体的颜色
					);
				}
			}
		}
	}

	return LayerId;
}

//计算某个角度所对应的位置
void SCustomCurveList::GetEllipseOuterPoint(float InCenterX, float InCenterY, float Width, float Height, float angle, FVector2D& InPoint) const
{
	float Inside_R = Width * Height / FMath::Sqrt(FMath::Pow(Width * FMath::Sin(angle), 2) + FMath::Pow(Height * FMath::Cos(angle), 2));
	InPoint.X = InCenterX + Inside_R * FMath::Cos(angle);
	InPoint.Y = InCenterY + Inside_R * FMath::Sin(angle);
}

//非公线三点确定圆的圆心
FVector2D SCustomCurveList::tcircle(FVector2D pt1, FVector2D pt2, FVector2D pt3, float& radius)
{
	float x1 = pt1.X, x2 = pt2.X, x3 = pt3.X;
	float y1 = pt1.Y, y2 = pt2.Y, y3 = pt3.Y;
	float a = x1 - x2;
	float b = y1 - y2;
	float c = x1 - x3;
	float d = y1 - y3;
	float e = ((x1 * x1 - x2 * x2) + (y1 * y1 - y2 * y2)) / 2.0;
	float f = ((x1 * x1 - x3 * x3) + (y1 * y1 - y3 * y3)) / 2.0;
	float det = b * c - a * d;
	if (fabs(det) < 1e-5)
	{
		radius = -1;
		return FVector2D(0, 0);
	}

	float x0 = -(d * e - b * f) / det;
	float y0 = -(a * f - c * e) / det;
	radius = hypot(x1 - x0, y1 - y0);
	return FVector2D(x0, y0);
}

//直线转曲线
TArray<FVector2D> SCustomCurveList::StraightLineToCurveLine(TArray<FVector2D> InStraightLine)
{
	TArray<FVector2D> CurveLine;

	if (InStraightLine.Num() < 3)
		return InStraightLine;
	CenterS.Empty();
	//圆弧的思路一共进行了三个版本的迭代
	//版本1.通过两个坐标点和一个角度来确定了圆心的位置,找到了圆心再进行画两点之间的圆弧,下面代码有效但是展现出的效果过于生硬
	//版本2.通过3点坐标确定了圆心的位置,展现出的圆弧相比较版本1揉合了许多,但转折点还是有生应的情况
	for (int i = 1; i < InStraightLine.Num(); i++)
	{
		/*{//下面这套方案是可以画出圆弧的但是效果不好转折点过于生硬
			FVector2D LeftPoint = InStraightLine[i - 1];
			FVector2D RightPoint = InStraightLine[i];
			//弧度2-45(2接近于直线)

			float Width = RightPoint.X - LeftPoint.X;
			float MaxHeight = Size.Y;
			//利用勾股定理算出这个三角形的斜边,就是两个点之间的最大距离
			float MaxLeng = FMath::Sqrt(Width * Width + MaxHeight * MaxHeight);
			//在算出当前两个点的距离
			float PointDiffer = FMath::Abs(LeftPoint.Y - RightPoint.Y);
			float PointLeng = FMath::Sqrt(PointDiffer * PointDiffer + Width * Width);

			//计算这两个点的角度的差距
			float AngInterval = PointLeng / MaxLeng * HuDu;
			//接下来计算这两个点共同的圆心
			//得到这两个点的共同圆心
			FVector2D Center = GetCenterPoint(LeftPoint, RightPoint, AngInterval, false);
			CenterS.Add(Center);
			//计算半径
			float Radius = FMath::Sqrt(FMath::Square(LeftPoint.X - Center.X) + FMath::Square(LeftPoint.Y - Center.Y));
			for (float j = 0; j < RightPoint.X - LeftPoint.X; j += 0.1)
			{
				float Y = FMath::Sqrt(FMath::Square(Radius) - FMath::Square((LeftPoint.X + j) - Center.X));
				CurveLine.Add(FVector2D((LeftPoint.X + j), Center.Y - Y));
			}
		}*/

		if (i == InStraightLine.Num() - 2)
		{
			FVector2D Center;
			float Radius;
			Center = tcircle(InStraightLine[i - 1], InStraightLine[i], InStraightLine[i + 1], Radius);
			CenterS.Add(Center);
			for (float j = 0; j < InStraightLine[i + 1].X - InStraightLine[i - 1].X; j += 0.1)
			{
				float Y = FMath::Sqrt(FMath::Square(Radius) - FMath::Square((InStraightLine[i - 1].X + j) - Center.X));
				if (InStraightLine[i].Y < Center.Y)
				{
					CurveLine.Add(FVector2D((InStraightLine[i - 1].X + j), Center.Y - Y));
				}
				else
				{
					CurveLine.Add(FVector2D((InStraightLine[i - 1].X + j), Center.Y + Y));
				}
			}
			break;
		}
		else
		{
			FVector2D Center;
			float Radius;
			Center = tcircle(InStraightLine[i - 1], InStraightLine[i], InStraightLine[i + 1], Radius);
			CenterS.Add(Center);
			for (float j = 0; j < InStraightLine[i].X - InStraightLine[i - 1].X; j += 0.1)
			{
				float Y = FMath::Sqrt(FMath::Square(Radius) - FMath::Square((InStraightLine[i - 1].X + j) - Center.X));
				if (InStraightLine[i].Y < Center.Y)
				{
					CurveLine.Add(FVector2D((InStraightLine[i - 1].X + j), Center.Y - Y));
				}
				else
				{
					CurveLine.Add(FVector2D((InStraightLine[i - 1].X + j), Center.Y + Y));
				}
			}
		}
	}

	return CurveLine;
}

TArray<FVector2D> SCustomCurveList::GetAllYPoint(TArray<FVector2D> InStraightLine) const
{
	TArray<FVector2D> TempLines;
	TArray<FVector2D> ResLines;
	if (InStraightLine.Num() < 2)
		return InStraightLine;

	//弧线向外
	bool IsOut = true;
	for (int i = 1; i < InStraightLine.Num(); i++)
	{
		FVector2D LeftPoint = InStraightLine[i - 1];
		FVector2D RightPoint = InStraightLine[i];
		if (LeftPoint.Y < RightPoint.Y)
		{
			//以下是三角函数的计算
			float height = FMath::Abs(LeftPoint.Y - RightPoint.Y);
			float width = RightPoint.X - LeftPoint.X;
			float Compare = width / height;
			for (int j = width, item = 0; j >= 0; j--, item++)
			{
				float NewHeight = j / Compare;
				TempLines.Add(FVector2D(LeftPoint.X + item, RightPoint.Y - NewHeight));
			}
		}
		else
		{
			//直接用的相似三角形原理进行计算
			float height = FMath::Abs(LeftPoint.Y - RightPoint.Y);
			float width = RightPoint.X - LeftPoint.X;
			float Compare = width / height;
			for (int j = 0; j <= width; j++)
			{
				float NewHeight = j / Compare;
				TempLines.Add(FVector2D(LeftPoint.X + j, LeftPoint.Y - NewHeight));
			}
		}
	}
	int item = 0;
	ResLines.Add(TempLines[0]);
	for (int i = 1; i < TempLines.Num(); i++)
	{
		if (TempLines[i].X > ResLines[item].X)
		{
			ResLines.Add(TempLines[i]);
			item++;
		}
	}
	return ResLines;
}

void SCustomCurveList::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
{
	SCompoundWidget::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);
	if (!SizeUpdata)
	{
		FGeometry ZeroGeometry = SpacerDrawArea->GetCachedGeometry();
		if (!(ZeroGeometry.AbsolutePosition.X == 0 && ZeroGeometry.AbsolutePosition.Y == 0))
		{
			FGeometry OneListGeometry = GetCachedGeometry(); //获取自己再软件中的位置
			//起始位置
			BeginPoint;
			BeginPoint.X = ZeroGeometry.AbsolutePosition.X - OneListGeometry.AbsolutePosition.X;
			BeginPoint.Y = ZeroGeometry.AbsolutePosition.Y - OneListGeometry.AbsolutePosition.Y;
			//尺寸
			Size = ZeroGeometry.Size;
			//调整DPI
			BeginPoint /= AllottedGeometry.Scale;
			SizeUpdata = true;


			//每个点在X坐标轴上的位置
			TArray<int> XPoint;
			//每个点在Y坐标轴上的位置
			TArray<TArray<int>> YPoint;
			//首先算出转折点的位置
			int ValueNum = ListData.Num();
			//算出间隔
			int Interval = Size.X / ValueNum;

			for (int i = 0; i < ValueNum; i++)
			{
				XPoint.Add(Interval / 2 + i * Interval + BeginPoint.X);
			}
			OnePointS.Empty();
			TwoPointS.Empty();
			ThreePointS.Empty();
			FourPointS.Empty();
			OnePointY.Empty();
			TwoPointY.Empty();
			ThreePointY.Empty();
			FourPointY.Empty();
			//计算Y轴坐标
			for (auto& item : ListData)
			{
				TArray<int> GroupY;
				if (PillarNum >= 1)
				{
					GroupY.Add(Size.Y - (item.Value.OneValue / MaxValue * Size.Y) + BeginPoint.Y);
				}
				if (PillarNum >= 2)
				{
					GroupY.Add(Size.Y - (item.Value.TwoValue / MaxValue * Size.Y) + BeginPoint.Y);
				}
				if (PillarNum >= 3)
				{
					GroupY.Add(Size.Y - (item.Value.ThreeValue / MaxValue * Size.Y) + BeginPoint.Y);
				}
				if (PillarNum >= 4)
				{
					GroupY.Add(Size.Y - (item.Value.FourValue / MaxValue * Size.Y) + BeginPoint.Y);
				}
				YPoint.Add(GroupY);
			}

			//先加上一段随机数
			if (PillarNum >= 1)
			{
				OnePointS.Add(FVector2D(BeginPoint.X, Size.Y - (BeginRand.OneValue / MaxValue * Size.Y) + BeginPoint.Y));
			}
			if (PillarNum >= 2)
			{
				TwoPointS.Add(FVector2D(BeginPoint.X, Size.Y - (BeginRand.TwoValue / MaxValue * Size.Y) + BeginPoint.Y));
			}
			if (PillarNum >= 3)
			{
				ThreePointS.Add(FVector2D(BeginPoint.X, Size.Y - (BeginRand.ThreeValue / MaxValue * Size.Y) + BeginPoint.Y));
			}
			if (PillarNum >= 4)
			{
				FourPointS.Add(FVector2D(BeginPoint.X, Size.Y - (BeginRand.FourValue / MaxValue * Size.Y) + BeginPoint.Y));
			}
			for (int i = 0; i < ValueNum; i++)
			{
				if (PillarNum >= 1)
				{
					OnePointS.Add(FVector2D(XPoint[i], YPoint[i][0]));
				}
				if (PillarNum >= 2)
				{
					TwoPointS.Add(FVector2D(XPoint[i], YPoint[i][1]));
				}
				if (PillarNum >= 3)
				{
					ThreePointS.Add(FVector2D(XPoint[i], YPoint[i][2]));
				}
				if (PillarNum >= 4)
				{
					FourPointS.Add(FVector2D(XPoint[i], YPoint[i][3]));
				}
			}
			//先加上一段随机数
			if (PillarNum >= 1)
			{
				OnePointS.Add(FVector2D(Size.X + BeginPoint.X, Size.Y - (EndRang.OneValue / MaxValue * Size.Y) + BeginPoint.Y));
			}
			if (PillarNum >= 2)
			{
				TwoPointS.Add(FVector2D(Size.X + BeginPoint.X, Size.Y - (EndRang.TwoValue / MaxValue * Size.Y) + BeginPoint.Y));
			}
			if (PillarNum >= 3)
			{
				ThreePointS.Add(FVector2D(Size.X + BeginPoint.X, Size.Y - (EndRang.ThreeValue / MaxValue * Size.Y) + BeginPoint.Y));
			}
			if (PillarNum >= 4)
			{
				FourPointS.Add(FVector2D(Size.X + BeginPoint.X, Size.Y - (EndRang.FourValue / MaxValue * Size.Y) + BeginPoint.Y));
			}

			//显示圆弧
			if (UseCurveLine)
			{
				if (PillarNum >= 1)
				{
					OnePointS = StraightLineToCurveLine(OnePointS);
				}
				if (PillarNum >= 2)
				{
					TwoPointS = StraightLineToCurveLine(TwoPointS);
				}
				if (PillarNum >= 3)
				{
					ThreePointS = StraightLineToCurveLine(ThreePointS);
				}
				if (PillarNum >= 4)
				{
					FourPointS = StraightLineToCurveLine(FourPointS);
				}
			}
			//如果显示面积
			if (ShowArea)
			{
				if (UseCurveLine)
				{
					if (PillarNum >= 1)
					{
						OnePointY.Empty();
						OnePointY.Add(FVector2D((int)OnePointS[0].X, OnePointS[0].Y));
						for (int i = 1; i < OnePointS.Num(); i++)
						{
							int LastItem = OnePointY.Num() - 1;
							if ((int)OnePointS[i].X > OnePointY[LastItem].X)
							{
								OnePointY.Add(FVector2D((int)OnePointS[i].X, OnePointS[i].Y));
							}
						}
					}
					if (PillarNum >= 2)
					{
						TwoPointY.Empty();
						TwoPointY.Add(FVector2D((int)TwoPointS[0].X, TwoPointS[0].Y));
						for (int i = 1; i < TwoPointS.Num(); i++)
						{
							int LastItem = TwoPointY.Num() - 1;
							if ((int)TwoPointS[i].X > TwoPointY[LastItem].X)
							{
								TwoPointY.Add(FVector2D((int)TwoPointS[i].X, TwoPointS[i].Y));
							}
						}
					}
					if (PillarNum >= 3)
					{
						ThreePointY.Empty();
						ThreePointY.Add(FVector2D((int)ThreePointS[0].X, ThreePointS[0].Y));
						for (int i = 1; i < ThreePointS.Num(); i++)
						{
							int LastItem = ThreePointY.Num() - 1;
							if ((int)ThreePointS[i].X > ThreePointY[LastItem].X)
							{
								ThreePointY.Add(FVector2D((int)ThreePointS[i].X, ThreePointS[i].Y));
							}
						}
					}
					if (PillarNum >= 4)
					{
						FourPointY.Empty();
						FourPointY.Add(FVector2D((int)FourPointS[0].X, FourPointS[0].Y));
						for (int i = 1; i < FourPointS.Num(); i++)
						{
							int LastItem = FourPointY.Num() - 1;
							if ((int)FourPointS[i].X > FourPointY[LastItem].X)
							{
								FourPointY.Add(FVector2D((int)FourPointS[i].X, FourPointS[i].Y));
							}
						}
					}
				}
				else
				{
					if (PillarNum >= 1)
					{
						OnePointY = GetAllYPoint(OnePointS);
					}
					if (PillarNum >= 2)
					{
						TwoPointY = GetAllYPoint(TwoPointS);
					}
					if (PillarNum >= 3)
					{
						ThreePointY = GetAllYPoint(ThreePointS);
					}
					if (PillarNum >= 4)
					{
						FourPointY = GetAllYPoint(FourPointS);
					}
				}
			}
		}
	}
}


//已知圆上两点和圆心角求圆心坐标
//https://zhidao.baidu.com/question/2266146971106275348.html
FVector2D SCustomCurveList::GetCenterPoint(FVector2D PointOne, FVector2D PointTwo, float Ang, bool IsPlusPlus)
{
	FVector2D CenterPoint;
	float tan = FMath::Tan(M_PI * (Ang / 180.0));
	//if(IsPlusPlus)
	{
		int X1, X2;
		int Y1, Y2;
		X1 = (PointOne.X + PointTwo.X) / 2 + (PointOne.Y - PointTwo.Y) / (tan * 2);
		X2 = (PointOne.X + PointTwo.X) / 2 - (PointOne.Y - PointTwo.Y) / (tan * 2);
		Y1 = (PointOne.Y + PointTwo.Y) / 2 + (PointTwo.X - PointOne.X) / (tan * 2);
		Y2 = (PointOne.Y + PointTwo.Y) / 2 - (PointTwo.X - PointOne.X) / (tan * 2);
		if (PointOne.Y < PointTwo.Y)
		{
			return FVector2D(X1 < X2 ? X1 : X2,
			                 Y1 < Y2 ? Y2 : Y1);
		}
		else
		{
			return FVector2D(X1 < X2 ? X2 : X1,
			                 Y1 < Y2 ? Y2 : Y1);
		}
	}
	/*else
	{
		CenterPoint.X = (PointOne.X + PointTwo.X ) / 2 - (PointOne.Y - PointTwo.Y) /(tan * 2);
		CenterPoint.Y = (PointOne.Y + PointTwo.Y ) / 2 + (PointTwo.X - PointOne.X) /(tan * 2);
	}*/
	return CenterPoint;
}

void SCustomCurveList::UpDataList(TMap<FString, FCustomCurveListInfo> InListData)
{
	ListData = InListData;
	CopyListData = InListData;

	UpdataCustomCurveList();
}

int SCustomCurveList::FloatAccuracy(int &MaxLen)
{
	TArray<FString> NumList;
	//精确度
	int AccuracyNum = 0;
	//先转成字符串
	for (float item = MaxValue;;MaxValue > MinValue?  item -= GrowValue :  item += GrowValue)
	{
		if (MaxValue > MinValue)
		{
			if (item <= MinValue)
				break;
		}
		else
		{
			if (item >= MinValue)
				break;
		}
		NumList.Add(FString::Printf(TEXT("%f"), item));
	}

	for(int i = 0; i< NumList.Num();i++)
	{
		int32 WildCardIndex = INDEX_NONE;
		//找到这个"."
		if (NumList[i].FindChar(TEXT('.'), WildCardIndex))
		{
			//获取小数点后面的数值
			FString DianRight = NumList[i].Right(NumList[i].Len() - (WildCardIndex + 1));
			int FindItem = DianRight.Find(TEXT("00"));
			if(FindItem == INDEX_NONE)
			{
				FindItem = DianRight.Find(TEXT("99"));
			}
			if(FindItem != INDEX_NONE)
			{
				if(FindItem > AccuracyNum)
				AccuracyNum = FindItem;
			}
		}
	}

	if(AccuracyNum != 0)
	{
		for(int i = 0; i < NumList.Num();i++)
		{
			int32 WildCardIndex = INDEX_NONE;
			//找到这个"."
			if (NumList[i].FindChar(TEXT('.'), WildCardIndex))
			{
				if(WildCardIndex + 1 + AccuracyNum > MaxLen)
					MaxLen = WildCardIndex + 1 + AccuracyNum;
			}
		}
	}
	else
	{
		MaxLen = FMath::Max(FString::SanitizeFloat(MaxValue).Len(),
							FString::SanitizeFloat(MinValue).Len()); //最大字符长度
	}
	return AccuracyNum;
}
//保留精确度多余的部分进行剔除
FString SCustomCurveList::GetFloatAccuracy(float Value, int Accuracy)
{
	FString Ref = FString::SanitizeFloat(Value);
	if (Ref.Len() > 2 && !Ref.Right(2).Compare(".0"))
	{
		Ref = Ref.Left(Ref.Len() - 2);
	}
	int32 WildCardIndex = INDEX_NONE;
	//找到这个"."
	if (Ref.FindChar(TEXT('.'), WildCardIndex))
	{
		
		int StrLen = WildCardIndex + 1 + Accuracy;
		if(StrLen < Ref.Len())
		{
			FString RightStr = Ref.Right(Ref.Len() - StrLen);
			Ref = Ref.Left(StrLen);
			//判断被截断的是否是99,如果是则Ref位数+1
			if(RightStr.Len() >= 2 && !RightStr.Left(2).Compare("99"))
			{
					TCHAR *ch = GetData(Ref);
				for(int i = Ref.Len() - 1;i >= 0;i--)
				{
					if(ch[i] == '.')
						continue;
					if(ch[i] != '9')
					{
						ch[i] += 1;
						break;
					}
					else
					{
						ch[i] = '0';
					}
				}
			}
		}
	}
	return Ref;
}

void SCustomCurveList::UpdataCustomCurveList()
{

	UpdataMinMaxValue();
	YuanImageS.Empty();
	BeginRand.OneValue = MinValue;
	BeginRand.TwoValue = MinValue;
	BeginRand.ThreeValue = MinValue;
	BeginRand.FourValue = MinValue;
	EndRang.OneValue = MinValue;
	EndRang.TwoValue = MinValue;
	EndRang.ThreeValue = MinValue;
	EndRang.FourValue = MinValue;
	//生成随机数
	if (UseRand)
	{
		BeginRand.OneValue = FMath::RandRange(MinValue, MaxValue);
		BeginRand.TwoValue = FMath::RandRange(MinValue, MaxValue);
		BeginRand.ThreeValue = FMath::RandRange(MinValue, MaxValue);
		BeginRand.FourValue = FMath::RandRange(MinValue, MaxValue);
		EndRang.OneValue = FMath::RandRange(MinValue, MaxValue);
		EndRang.TwoValue = FMath::RandRange(MinValue, MaxValue);
		EndRang.ThreeValue = FMath::RandRange(MinValue, MaxValue);
		EndRang.FourValue = FMath::RandRange(MinValue, MaxValue);
	}
	else if (ListData.Num() > 0)
	{
		int i = 0;
		for (auto& item : ListData)
		{
			if (i == 0)
			{
				BeginRand.OneValue = item.Value.OneValue;
				BeginRand.TwoValue = item.Value.TwoValue;
				BeginRand.ThreeValue = item.Value.ThreeValue;
				BeginRand.FourValue = item.Value.FourValue;
			}
			if (i == ListData.Num() - 1)
			{
				EndRang.OneValue = item.Value.OneValue;
				EndRang.TwoValue = item.Value.TwoValue;
				EndRang.ThreeValue = item.Value.ThreeValue;
				EndRang.FourValue = item.Value.FourValue;
			}
			i++;
		}
	}

	
	int MaxLen = 0;
	//获取小数点后面的精确度
	int AccuracyNum = FloatAccuracy(MaxLen);
	TSharedPtr<SVerticalBox> DrawLine = SNew(SVerticalBox);
	for (float item = MaxValue;; MaxValue > MinValue ? item -= GrowValue : item += GrowValue)
	{
		if (MaxValue > MinValue)
		{
			if (item <= MinValue)
				break;
		}
		else
		{
			if (item >= MinValue)
				break;
		}
		//为了应对浮点数的精度问题
		if (FMath::Abs(item - MinValue) < 0.00001)
			continue;
		FString ValueStr = GetFloatAccuracy(item,AccuracyNum);
		if (ValueStr.Len() > 1 && !ValueStr.Right(1).Compare("."))
		{
			ValueStr = ValueStr.Left(ValueStr.Len() - 1);
		}
		if (ValueStr.Len() < MaxLen)
		{
			int AddSpace = MaxLen - ValueStr.Len();
			FString Space = "";
			for (int i = 0; i < AddSpace; i++)
			{
				Space.Append("  ");
			}
			ValueStr = Space + ValueStr;
		}
		if (!UseRuler)
		{
			ValueStr = "";
		}
		DrawLine->AddSlot().FillHeight(1)
		[
			SNew(SHorizontalBox)
			+ SHorizontalBox::Slot().AutoWidth().Padding(FMargin(0, -10, 0, 0))
			[
				SNew(STextBlock_TextStyleLambda_List)
             			.Justification(ETextJustify::Right)
             			.Text(FText::FromString(ValueStr))
             			.TEXTSTYLE("AlibabaRegular_12_83AAD6FF")
			]
			+ SHorizontalBox::Slot()
			  .Padding(FMargin(12, 0, 0, 0))
			  .FillWidth(1)
			[
				SNew(SVerticalBox)
				+ SVerticalBox::Slot().AutoHeight()
				[
					SNew(SBox).HeightOverride(1)
					[
						SNew(SImage).SETIMAGE("XuXian")
					]
				]
				+ SVerticalBox::Slot().FillHeight(1)
				[
					SNew(SSpacer)
				]
			]
		];
	}


	//用于显示图表中背景的线和柱子
	TSharedPtr<SOverlay> List_SOverlay = SNew(SOverlay);
	//用于显示柱子对应的名字
	TSharedPtr<SHorizontalBox> NameLise = SNew(SHorizontalBox);


	for (auto& item : ListData)
	{
		NameLise->AddSlot().FillWidth(1)
		[

			SNew(SMultiLineEditableText)
			.Justification(ETextJustify::Center)
				.TextStyle(ListUIStyle::GetTextBlockStyle("AlibabaRegular_10_83AAD6FF"))
				 .IsReadOnly(true) //只读属性
				 .AutoWrapText(true)
				 .ToolTipText(FText::FromString(item.Key))
				 .Text(FText::FromString(item.Key))
		];
	}

	FString TempStr = "";
	FString MinValueStr = GetFloatAccuracy(MinValue,AccuracyNum);
	if (MinValueStr.Len() > 1 && !MinValueStr.Right(1).Compare("."))
	{
		MinValueStr = MinValueStr.Left(MinValueStr.Len() - 1);
	}
	int MinValueLen = MinValueStr.Len();
	for (int i = 0; i < MaxLen - MinValueLen; i++)
		TempStr.Append("  ");

	if (UseRuler)
	{
		MinValueStr = TempStr + MinValueStr;
	}
	else
	{
		MinValueStr = " " + MinValueStr;
	}

	List_SOverlay->AddSlot()
	[
		DrawLine.ToSharedRef()
	];
	List_SOverlay->AddSlot()[
		SNew(SHorizontalBox)
		+ SHorizontalBox::Slot().AutoWidth()
		[
			SNew(STextBlock_TextStyleLambda_List)
				 .Justification(ETextJustify::Right)
				 .Text(FText::FromString(TempStr))
				 .TEXTSTYLE("AlibabaRegular_12_83AAD6FF")
		]
		+ SHorizontalBox::Slot().FillWidth(1).Padding(FMargin(12 * MinValueLen, 0, 0, 0))
		[
			SAssignNew(SpacerDrawArea, SSpacer)
		]
	];

	//显示整个表格
	TSharedPtr<SVerticalBox> ShowList;
	SAssignNew(ShowList, SVerticalBox)
		+ SVerticalBox::Slot().FillHeight(1)
		[
			List_SOverlay.ToSharedRef()
		]
		+ SVerticalBox::Slot().AutoHeight()
		[
			SNew(SBox).HeightOverride(1)
			[
				SNew(SHorizontalBox)
				+ SHorizontalBox::Slot().AutoWidth()
				[
					SNew(STextBlock_TextStyleLambda_List)
					 .Justification(ETextJustify::Right)
					 .Text(FText::FromString(TempStr))
					 .TEXTSTYLE("AlibabaRegular_12_83AAD6FF")
				]
				+ SHorizontalBox::Slot().FillWidth(1).Padding(FMargin(12 * MinValueLen, 0, 0, 0))
				[
					SNew(SColorBlock).Color(FLinearColor(0.27, 0.4, 0.67, 1.0))
				]
			]
		]
		+ SVerticalBox::Slot().AutoHeight()
		[
			SNew(SHorizontalBox)
			+ SHorizontalBox::Slot().AutoWidth().Padding(FMargin(0, -10, 0, 0))
			[
				SNew(STextBlock_TextStyleLambda_List)
						 .Justification(ETextJustify::Right)
						 .Text(FText::FromString(MinValueStr))
						 .TEXTSTYLE("AlibabaRegular_12_83AAD6FF")
			]
			+ SHorizontalBox::Slot().FillWidth(1).Padding(FMargin(12, 0, 0, 0))
			[
				NameLise.ToSharedRef()
			]
		];

	ListContent->SetContent(ShowList.ToSharedRef());


	//做数据映射,不论数值的最小值和最大值是什么,全都映射到0-100,对应的参数也映射到0-100;
	Intervalmapping();
	if (ListData.Num() > 0)
		SizeUpdata = false;
}

void SCustomCurveList::UpdataMinMaxValue()
{
	float _minValue,_maxValue;
	bool first = false;
	if(PillarNum >= 1)
	{
		for (auto &item : ListData)
		{
			if(!first)
			{
				_minValue = _maxValue = item.Value.OneValue;
				first = true;
			}
			else
			{
				if(item.Value.OneValue > _maxValue)
				{
					_maxValue = item.Value.OneValue;
				}
				if(item.Value.OneValue < _minValue)
				{
					_minValue = item.Value.OneValue;
				}
			}
		}
	}
	if(PillarNum >= 2)
	{
		for (auto &item : ListData)
		{
			if(item.Value.TwoValue > _maxValue)
			{
				_maxValue = item.Value.TwoValue;
			}
			if(item.Value.TwoValue < _minValue)
			{
				_minValue = item.Value.TwoValue;
			}
		}
	}
	if(PillarNum >= 3)
	{
		for (auto &item : ListData)
		{
			if(item.Value.ThreeValue > _maxValue)
			{
				_maxValue = item.Value.ThreeValue;
			}
			if(item.Value.ThreeValue < _minValue)
			{
				_minValue = item.Value.ThreeValue;
			}
		}
	}
	if(PillarNum >= 4)
	{
		for (auto &item : ListData)
		{
			if(item.Value.FourValue > _maxValue)
			{
				_maxValue = item.Value.FourValue;
			}
			if(item.Value.FourValue < _minValue)
			{
				_minValue = item.Value.FourValue;
			}
		}
	}

	if(_maxValue == _minValue)
		_minValue = 0;
	float interval = FMath::Abs(_maxValue - _minValue);
	if(interval == 0 || first == false)
		return;
	
	if(MaxValue > MinValue && (_maxValue >MaxValue || _minValue < MinValue))
	{
		MaxValue = _maxValue;
		MinValue = _minValue;
		GrowValue = (MaxValue - MinValue) / 5;
	}
	if(MinValue > MaxValue && (_maxValue < MaxValue || _minValue > MinValue))
	{
		MaxValue = _minValue;
		MinValue = _maxValue;
		GrowValue = (MaxValue - MinValue) / 5;
	}
}

void SCustomCurveList::Intervalmapping()
{
	BeginRand.OneValue = UKismetMathLibrary::MapRangeUnclamped(BeginRand.OneValue, MinValue, MaxValue, 0, 100);
	BeginRand.TwoValue = UKismetMathLibrary::MapRangeUnclamped(BeginRand.TwoValue, MinValue, MaxValue, 0, 100);
	BeginRand.ThreeValue = UKismetMathLibrary::MapRangeUnclamped(BeginRand.ThreeValue, MinValue, MaxValue, 0, 100);
	BeginRand.FourValue = UKismetMathLibrary::MapRangeUnclamped(BeginRand.FourValue, MinValue, MaxValue, 0, 100);
	EndRang.OneValue = UKismetMathLibrary::MapRangeUnclamped(EndRang.OneValue, MinValue, MaxValue, 0, 100);
	EndRang.TwoValue = UKismetMathLibrary::MapRangeUnclamped(EndRang.TwoValue, MinValue, MaxValue, 0, 100);
	EndRang.ThreeValue = UKismetMathLibrary::MapRangeUnclamped(EndRang.ThreeValue, MinValue, MaxValue, 0, 100);
	EndRang.FourValue = UKismetMathLibrary::MapRangeUnclamped(EndRang.FourValue, MinValue, MaxValue, 0, 100);

	for (auto& item : ListData)
	{
		item.Value.OneValue = UKismetMathLibrary::MapRangeUnclamped(item.Value.OneValue, MinValue, MaxValue, 0, 100);
		item.Value.TwoValue = UKismetMathLibrary::MapRangeUnclamped(item.Value.TwoValue, MinValue, MaxValue, 0, 100);
		item.Value.ThreeValue = UKismetMathLibrary::MapRangeUnclamped(item.Value.ThreeValue, MinValue, MaxValue, 0, 100);
		item.Value.FourValue = UKismetMathLibrary::MapRangeUnclamped(item.Value.FourValue, MinValue, MaxValue, 0, 100);
	}
	MinValue = UKismetMathLibrary::MapRangeUnclamped(MinValue, MinValue, MaxValue, 0, 100);
	MaxValue = UKismetMathLibrary::MapRangeUnclamped(MaxValue, MinValue, MaxValue, 0, 100);
}


void SCustomCurveList::UpDataTitleName(const FString InTitleName)
{
	TitleText->SetText(FText::FromString(InTitleName));
}

void SCustomCurveList::UpDataOneInfoName(const FString InOneInfoName)
{
	OneInfo->SetText(FText::FromString(InOneInfoName));
}

void SCustomCurveList::UpDataTwoInfoName(const FString InFourInfoName)
{
	TwoInfo->SetText(FText::FromString(InFourInfoName));
}

void SCustomCurveList::UpDataThreeInfoName(const FString InThreeInfoName)
{
	ThreeInfo->SetText(FText::FromString(InThreeInfoName));
}

void SCustomCurveList::UpDataFourInfoName(const FString InFourInfoName)
{
	FourInfo->SetText(FText::FromString(InFourInfoName));
}

void SCustomCurveList::CleanList()
{
	UpDataList(TMap<FString, FCustomCurveListInfo>());
}

FReply SCustomCurveList::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
	SCompoundWidget::OnMouseWheel(MyGeometry, MouseEvent);
	return FReply::Handled();
}

FReply SCustomCurveList::OnMouseButtonDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent)
{
	SCompoundWidget::OnMouseButtonDoubleClick(InMyGeometry, InMouseEvent);
	return FReply::Handled();
}

FReply SCustomCurveList::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
	SCompoundWidget::OnMouseMove(MyGeometry, MouseEvent);
	return FReply::Handled();
}

FReply SCustomCurveList::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
	SCompoundWidget::OnMouseButtonDown(MyGeometry, MouseEvent);
	return FReply::Handled();
}